  

using System;
    using System.Collections.Generic;
    using MySql.Data.MySqlClient;   
using System.Text;
using System.IO;
using System.Data;
using System.Web;
public partial class banners
{
 
   public static List< banners > getListByPortal(int idportal)
  {
 
      List< banners > listabanners = new List< banners >();
            MySqlDataReader reg;
            string sqlt;
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sqlt = "select idBanners,posicion,imagen,url,nombre,libre from banners where idportal=" + idportal;
            reg = db.sql(sqlt);
            while (reg.Read())
                {
               banners pp = new banners();
  
  
           pp.idBanners = sf.entero(reg["idBanners"].ToString());
                       
  
  
           pp.posicion = sf.entero(reg["posicion"].ToString());
                       
  
  
               pp.imagen = sf.cadena(reg["imagen"].ToString());
                   
  
  
               pp.url = sf.cadena(reg["url"].ToString());
                   
  
  
               pp.nombre = sf.cadena(reg["nombre"].ToString());
                   
  
  
                       pp.libre = sf.Bool(reg["libre"].ToString());
           
               listabanners.Add(pp);
               }
            reg.Close();
            }
            catch (Exception ex)
            {
                 
            }
            finally
            {
                db.Dispose();
              
            }
            return listabanners;
       }  
 
// returns number of registers in the table... (for pagination)
 public static int getCount ()
  {
           
            MySqlDataReader reg;
            string sqlt;
            int retorno=0;
           
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sqlt = "select count(*) as cont from banners";
                     
            reg = db.sql(sqlt);
            if (reg.Read()) 
   {
    retorno=sf.entero(reg["cont"].ToString());
   }
            else retorno=0;
               
            reg.Close();
            }
            catch (Exception ex)
            {
                // Argument is optional, no "When" keyword 
            }
            finally
            {
                db.Dispose();
              
            }
            return  retorno;
       } // count
 
 
 // devuelve una lista de banners para paginacion...
 
   public static List<banners> getPage(int num, int tamPag)
  {
      List< banners > listabanners = new List< banners >();
            MySqlDataReader reg;
            string sqlt;
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sqlt = "select idBanners,posicion,imagen,url,nombre,libre from banners limit " + sf.cadena(num*tamPag) + "," + sf.cadena(tamPag);
            reg = db.sql(sqlt);
            while (reg.Read())
                {
                banners pp = new banners();
           pp.idBanners = sf.entero(reg["idBanners"].ToString());
                              pp.posicion = sf.entero(reg["posicion"].ToString());
                                  pp.imagen = sf.cadena(reg["imagen"].ToString());
                              pp.url = sf.cadena(reg["url"].ToString());
                              pp.nombre = sf.cadena(reg["nombre"].ToString());
                                      pp.libre = sf.Bool(reg["libre"].ToString());
                      listabanners.Add(pp);
               }
            reg.Close();
            }
            catch (Exception ex)
            {
                 
            }
            finally
            {
                db.Dispose();
              
            }
            return listabanners;
       }  // getPage
 
 
 

 
}
 
